<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>self触发自己范围内的事件</title>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <link rel="stylesheet" href="./Css/self.css">

</head>

<body>
    <!-- 修饰符.self只会触发自己范围内的事件，不会包含子元素。 -->
    <div id="app">
        <center>
            <div class="outeer" @click.self="outer">
                <div class="middle" @click.self="middle">
                    <button @click.stop="inner">点击我(^_^)</button>
                </div>
            </div>
            <h1 style="margin-top: 20px;">{{message}}</h1>
        </center>
    </div>
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: '这里是self测试'
            },
            methods: {
                outer: function() {
                    console.log('outer:这里是外部是事件');
                    this.message = 'outer:这里是外部是事件';
                },
                middle: function() {
                    console.log('middle:这里是中间是事件');
                    this.message = 'middle:这里是中间是事件';
                },
                inner: function() {
                    console.log('inner:这里是按钮是事件');
                    this.message = 'inner:这里是按钮是事件';
                }
            }
        })
    </script>
</body>

</html>